<html ng-app="app">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link href="../../build/common/base.css" rel="stylesheet">
    <script type="text/javascript" src="../../build/common/base.js"></script>
    <script type="text/javascript" src="../../build/common/ngEdit.js"></script>
    <script type="text/javascript">
        var app = angular.module("app", ['base', 'baseDirective']);
        app.controller('ctrl', ['$scope', 'baseService', 'ArrayToolService', '$filter', function ($scope, baseService, ArrayToolService, $filter) {
            $scope.init = function () {

            };
            $scope.$root.$on('afterSaveEvent', function(event, data){
            	if(!data.r) $.Dialog.close(window);
            });
    		$scope.runTest = function(){
    			if(!$scope.data.invokeTarget){
    				$.Dialog.alert("请编写调用目标！",7);
    				return ;
    			}
    			var param={invokeTarget:$scope.data.invokeTarget,description:$scope.data.description};
    			baseService.postForm(__ctx+"/sys/scheduleJob/runTest",param).then(function(data){
    				$.Dialog.alert(data.msg,data.code=='200'?6:5); 
    			},function(error){alert(error);});
    		}            
        }]);
    </script>
</head>
<body ng-controller="ctrl" ng-init="init()">

    <div class="ibox-title">
        <a class="btn btn-primary fa-save" href="javascript:void(0)" ng-model="data" ab-save="/sys/scheduleJob/save">保存</a>
        <a href="javaScript:void(0)" class="btn btn-primary fa-reply" onclick="javascript:$.Dialog.close(window);">取消</a>
        <a href="javascript:void(0)" ng-click="runTest()" class="btn btn-primary fa-cog ">
            <span>测试执行</span>
        </a>        
    </div>

    <form name="form" ab-load="/sys/scheduleJob/get?id={id}" ng-model="data">
        <table class="form-table">
            <input type="hidden" ng-if="data.id" ng-model="data.id" />
            <tr>
                <th>任务分组</th>
                <td>
                    <input ng-model="data.group" ng-init="data.group='default'" ab-validate="{required:true}" class="form-control"/>
                </td>
            </tr>

            <tr>
                <th>计划名称</th>
                <td>
                    <input ng-model="data.name" ab-validate="{required:true}" class="form-control"/>
                </td>
            </tr>

            <tr>
                <th>运行表达式</th>
                <td>
                    <input ng-model="data.cronExpression" ng-init="data.cronExpression='* * * * *'" ab-validate="{required:true}" class="form-control" title="分0-59 时0-23 日1-31 月1-12 周1-7"/>
                </td>
            </tr>

            <tr>
                <th>是否并发执行</th>
                <td>
                    <label class="radio-inline"><input type="radio" checked value="1" ng-model="data.concurrent" ab-validate="{required:true}" />是</label>
                    <label class="radio-inline"><input type="radio" value="0" ng-model="data.concurrent" ab-validate="{required:true}" ng-init="data.concurrent='0'"/>否</label>
                </td>
            </tr>

            <tr>
                <th>运行状态</th>
                <td>
                    <select ng-model="data.runningState" class="form-control" ng-init="data.runningState='ENABLE'">
                        <option value="ENABLE" selected="selected">启用</option>
                        <option value="DISABLE">禁用</option>
                    </select>
                </td>
            </tr>

            <tr>
                <th>调用目标</th>
                <td>
                    <input ng-model="data.invokeTarget" ab-validate="{required:true}" class="form-control" title="class#method, runnable, script"/>
                </td>
            </tr>

            <tr>
                <th>任务计划说明</th>
                <td>
                    <textarea ng-model="data.description" ab-validate="{required:false}" class="form-control" rows="6"></textarea>
                </td>
            </tr>

        </table>

    </form>

</body>

</html>
